<template>
  <van-goods-action>
    <van-goods-action-icon :icon="ifSave ? 'star' : 'star-o'" :text="ifSave ? '已收藏' : '收藏'" :color="ifSave ? 'darkred' : '#666'" @click="ifSave=!ifSave" />
    <van-goods-action-icon icon="cart-o" text="购物车" :badge="badge" @click="gotoCart" />
    <van-goods-action-button type="danger" text="立即购买" @click="buyNow" />
    <van-goods-action-button type="warning" text="加入购物车" @click="addToCart"/>
  </van-goods-action>
</template>

<script>
export default {
  name: "MyGoodsAction",
  props: ['badge'],
  data() {
    return {
      ifSave: false
    }
  },
  methods: {
    buyNow() {
      this.$toast('您所在地区尚不支持购买')
    },
    // 点击加入购物车
    addToCart() {
      this.$emit('addToCart')
    },
    // 跳转到购物车
    gotoCart() {
      this.$router.push('/cart')
    }
  }
}
</script>

<style>
</style>